<?php
defined('BME_INSERTION') or die('Error code: '.BME_INVALID_INSERT_ERROR);

$mod = $_REQUEST[$_REQUEST["module"]];
$query=$header=$footer="";
if (ereg("^([^:]*):(.*)$",$mod,$reg)) {
	$mod = $reg[1];
	$query = $reg[2];
}
$mods = array("index","datasets","sequences","search_sequences");
$headers=$content=array();

if ( !in_array($mod,$mods) ) $mod = "index";
include(BME_ROOT."gui/mod/{$_REQUEST["module"]}.$mod.php");

if ( !empty($content) ) {
	if($nn>1){
	$headerIn="<div class='align_center'>%%query_showresults%%: ".
		html_a("$_rq:p1-5","5")." | ".
		html_a("$_rq:p1-25","25")." | ".html_a("$_rq:p1-50","50")." | ". html_a("$_rq:p1-100","100")." | ".
		html_a("$_rq:p1-$nn","%%query_showall%%")."<br/>".
	($footerIn=
		($p>2?html_a("$_rq:p1-$n","&laquo; %%query_first%%")." ":"").
		($p>1?html_a("$_rq:p".max($p-1,1)."-$n","&lsaquo; %%query_prev%%")." ":"").
		"(".($p*$n-$n+1)." - ".max(1,min($p*$n,$nn))." %%query_of%% ".max(1,$nn).") ".
		($p<$pp?html_a("$_rq:p".min($p+1,$pp)."-$n","%%query_next%% &rsaquo;")." ":"").
		($p<$pp-1&&$nn>1?html_a("$_rq:p$pp-$n","%%query_last%% &raquo;"):"")).
		"<br/>%%query_select%%: <a href='javascript:void(0);' onclick='checkAllBoxes(\"$_rq\")'>".
		"%%query_selectall%%</a>, <a href='javascript:void(0);' onclick='uncheckAllBoxes(\"$_rq\")'>".
		"%%query_selectnone%%</a><br/><br/>";
	$footerIn="<br/>$footerIn</div>".
		"<img onload=\"checkCheckBoxes('$_rq');par=this.parentNode;if(par)par.removeChild(this);\" ".
		"src='".BME_SITE."img/ajax-loader.gif'/>";
	}
	echo "$headerIn$header
	<table class='query'>";
	if(!empty($headers)){
		echo "<th>&nbsp;</th>";
		foreach ( $headers as $head )
			echo "<th>$head</th>";
	}
	foreach($content as $k=>$row){
		echo "<tr><td onclick='checkBox(\"$_rq\",\"check_$_rq/$k\")' class='check_cell'>".
			"<input type='checkbox' id='check_$_rq/$k' onclick='checkBox(\"$_rq\",\"check_$_rq/$k\")' style='display:none;'></td>";
		foreach ( $row as $cell )
			echo "<td>$cell</td>";
		echo "</tr>";
	}
	echo "</table>
	$footer$footerIn";
} else	echo "%%query_noresults%%";

?>
